package jdbc;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class jdbcdemo6
{
    public static void main(String[] args)
    {
        try(Connection con=DButil.getConnection();)
        {
           Statement sa=con.createStatement();
           String sql=" SELECT T.NAME,T.GENDER,C.NAME,C.FLOOR FROM TEACHER T JOIN CLASS C ON T.ID=C.TEACHER_ID WHERE T.NAME='王克晶'";
           ResultSet re=sa.executeQuery(sql);
           while(re.next())
           {
               String tname=re.getString("T.NAME");
               String gender=re.getString("T.GENDER");
               String cname=re.getString("C.NAME");
               String floor=re.getString("C.FLOOR");
               System.out.println(tname+","+gender+","+cname+","+floor);
           }
        } catch (SQLException e) {e.printStackTrace();}
    }
}
